package ltd.trackan.messagecenter.email.formatted;

import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * 京东资产统计 格式化
 * @author wxa
 */
public class JDAssets extends FormattedBasics {
    public JDAssets(String mailContent) {
        // 每个人信息分开
        String[] everyone = mailContent.split("--(-)*");
        // // 删除数组最后一位索引
        // everyone = Arrays.copyOfRange(everyone, 0, everyone.length - 1);
        // 删除除了数组第一索引之外所有索引开头的<br>
        for (int i = 1; i < everyone.length; i++) {
            everyone[i] = everyone[i].replaceFirst("<br>+", "");
        }
        List<String> collect = Arrays.stream(everyone).collect(Collectors.toList());
        for (int i = 0; i < everyone.length - 1; i++) {
            String userContent = collect.get(i);
            // 获得第一行
            String[] oneLine = userContent.split("<br>+");
            // 获得第一行的用户id
            Pattern pattern = Pattern.compile("】(\\S*)\\(");
            Matcher matcher = pattern.matcher(oneLine[0]);
            while (matcher.find()) {
                // 放入到双列集合里
                hashMap.put(matcher.group(1), userContent);
            }
            
        }
    }
}
